/*********************************************************************
***  tvm_define.h
***  the header file that contains some definition for TVM - Testify Virtual Machine
***
***  @author Tata @date 2008/12/31 Copyright(C) 2009 - Tata
*********************************************************************/

#ifndef _TVM_DEFINE_H_
#define _TVM_DEFINE_H_

#include "tvm_limits.h"
#include "tvm_utility.h"
#define TVM_HEADER_OFFSET						0
#define TVM_VERSION										1
#define TVM_VERSION_FIELD_OFFSET		(TVM_HEADER_OFFSET)
#define TVM_VERSION_FIELD_SIZE				1
#define TVM_PERIOD_FIELD_OFFSET			(TVM_VERSION_FIELD_OFFSET + TVM_VERSION_FIELD_SIZE)
#define TVM_PERIOD_FIELD_SIZE					1
#define TVM_SIZE_FIELD_OFFSET				(TVM_PERIOD_FIELD_OFFSET + TVM_PERIOD_FIELD_SIZE)
#define TVM_SIZE_FIELD_SIZE						2
#define TVM_HEADER_SIZE								(TVM_VERSION_FIELD_SIZE + TVM_PERIOD_FIELD_SIZE + TVM_SIZE_FIELD_SIZE)
#define TVM_CODE_START_ADDR					(TVM_HEADER_OFFSET + TVM_HEADER_SIZE)
#define TVM_CHECK_SUM_SIZE						(SIZE_OF_DWORD_IN_BYTE)
#define TVM_MIN_CODE_SIZE							4

#define TVM_MIN_SIZE								(TVM_HEADER_SIZE + TVM_CHECK_SUM_SIZE + TVM_MIN_CODE_SIZE)
#define TVM_MAX_SIZE								(UINT16_MAX)

#define TVM_MAX_LOG_MSG_LEN			(TVM_BUF_SIZE - 3)/*preserve 3 bytes for "\r\n\0"*/
#define TVM_MIN_INST_ADDR					(TVM_CODE_START_ADDR)
#define TVM_ADDR_SIZE							2



/*TVM state enumeration*/
#define TVM_STATE_STOPPED 			0
#define TVM_STATE_INIT						1/*being initialized*/
#define TVM_STATE_RUNNING			2
#define TVM_STATE_PAUSED				3
#define TVM_STATE_SLEEPING			4
#define TVM_STATE_RECORDING		5
#define TVM_STATE_WAITING			6/*waiting for an event to be triggered*/


/*TVM instructions' structure*/
#define INST_GROUP_BIT_START						5
#define INST_GROUP_BIT_END							7
#define INST_REG_SEL_BIT_START					3
#define INST_REG_SEL_BIT_END						4
#define INST_SIZE_IND_BIT_START					0
#define INST_SIZE_IND_BIT_END						2
#define INST_EVENT_SLOT_ID_BIT_START  	0
#define INST_EVENT_SLOT_ID_BIT_END	 		4


/*version & option byte structure*/
#define TVM_VER_BIT_START					0
#define TVM_VER_BIT_END						3
#define TVM_OPTION_BIT_START			4
#define TVM_OPTION_BIT_END				7
#define TVM_AUTO_LOG_START_BIT	0
#define TVM_AUTO_LOG_END_BIT		1
#define TVM_TRIAL_BIT							2


/*SX register's value*/
#define SX_EQUAL			0x1	/*ZF  1, SF  0*/
#define SX_BELOW			0x2	/*ZF  0, SF  1*/
#define SX_ABOVE			0x0	/*ZF  0, SF  0*/


/*TVM_BOOL values*/
#define TVM_FALSE  		0
#define TVM_TRUE  		1	

#define TVM_NULL			0


/*autolog state*/
#define TVM_AUTO_LOG_OFF				0
#define TVM_AUTO_LOG_LITE			1
#define TVM_AUTO_LOG_ALL				2

#endif/*_TVM_DEFINE_H_*/
